@extends('app')

@section('content')
<div class="loading" style=" font-size:20px;text-align:center;display:none;">
            <i class="icon-spinner icon-spin orange bigger-125"></i>
</div>

<ul class="nav nav-tabs">
    <li class="active"><a href="{{ url('/admin/teaches/organization/index')}}">信息列表</a></li>
    <li><a href="{{ url('/admin/teaches/organization/index/create') }}">信息添加</a></li>
</ul>

<div class="form-inline mt20">
    <div>
        <form id="exportform" enctype="multipart/form-data" method="post">
              <div class="form-group">
                <input type="file" name="report" id="uploadfile">

              </div>
           </form>
    </div>
</div>
<div class="panel panel-info mt20">
    <div class="panel-heading">筛选</div>
    <div class="panel-body">
        <form action="" method="get" class="form-horizontal" role="form" id="form1">
            <div class="input-group">
                <div class="input-group-addon">机构名称</div>
                <input class="form-control" name="title" type="text" value="{{$title}}" placeholder="课程名称">
                <div class="input-group-addon">分类</div>
                <select name="org_cate" class="form-control" >
                    <option value="0">--无--</option>
                    @foreach($type as $ty)
                    <option value="{{ $ty->cat_id }}" @if($cat_id == $ty->cat_id) selected @endif>{{ $ty->cat_name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group mt10">
                <div class="col-md-1 col-xs-12">
                    <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="panel panel-default mt20">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead>
            <tr>
                <th>编号</th>
                <th>标题</th>
                <th>种类</th>
                <th>电话</th>
                <th>发布时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach($news as $res)
            <tr id="news_{{ $res->id }}">
                <td>{{ $res->id }}</td>
                <td><a href="{{ url('admin/teaches/organization/index/'.$res->id.'/edit') }}">{{ $res->name }} </a></td>
                <td>{{ count($res->categorys)>0?$res->categorys->cat_name:'分类不存在' }}</td>
                <td>{{ $res->telphone}}</td>
                <td>{{ $res->updated_at}}</td>
                <td>
                    <a href="{{ url('/admin/teaches/organization/index/'.$res->id.'/edit') }}"><i class="glyphicon glyphicon-edit"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:void(0);" onclick="delete_one('/admin/teaches/organization/index/{{$res->id}}','{{$res->id}}','{{ csrf_token() }}')"><i class="glyphicon glyphicon-remove-sign"></i></a>
                </td>
            </tr>
            @endforeach
            </tbody>
        </table>
   </div>
</div>
<div>{!! $news->render() !!} </div>


<script type="text/javascript">
       $(function(){
        /***图片上传****/
        $("#uploadfile").uploadify({
            'formData'     : {
                'app':'organization',
                'fileField':'upfile',
                '_token':'{{ csrf_token() }}'
            },
            "width"           : 120,
            "height"          : 30,
            "queueSizeLimit"  :1,
            "swf"             : "{{ asset('/js/uploadify/uploadify.swf') }}",
            "fileObjName"     : "upfile",
            "buttonText"      : "导入Excel",
            "uploader"        : '/admin/teaches/organization/index/export',
            'removeTimeout'   : 1,
            'fileTypeExts'    : '*.jpg; *.png; *.gif;*.xlsx',
            'onSelect'        : function(){
                 $('.loading').css({'display': 'block'});
            },
            'onUploadSuccess':function(file, data, response){
                var data = eval('(' + data + ')');
                if(data.status == 'success'){
	                $('.loading').html(data.msg);
	                history.go(0);
                }else{
                	$('.loading').html(data.msg);
                	BootstrapDialog.alert({title:'错误提示',message:data.msg});
                }
            }
        });
    });
</script>
@endsection
